home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / scandir.man < prev    next >
Encoding:
Text File  |  1989-04-07  |  2.4 KB  |  67 lines

  1.  
  2.  
  3.  
  4. SCANDIR               C Library Procedures                SCANDIR
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      scandir, alphasort - scan a directory
  10.  
  11. SSYYNNOOPPSSIISS
  12.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  13.      ##iinncclluuddee <<ssyyss//ddiirr..hh>>
  14.  
  15.      ssccaannddiirr((ddiirrnnaammee,, nnaammeelliisstt,, sseelleecctt,, ccoommppaarr))
  16.      cchhaarr **ddiirrnnaammee;;
  17.      ssttrruucctt ddiirreecctt **((**nnaammeelliisstt[[]]));;
  18.      iinntt ((**sseelleecctt))(());;
  19.      iinntt ((**ccoommppaarr))(());;
  20.  
  21.      aallpphhaassoorrtt((dd11,, dd22))
  22.      ssttrruucctt ddiirreecctt ****dd11,, ****dd22;;
  23.  
  24. DDEESSCCRRIIPPTTIIOONN
  25.      _S_c_a_n_d_i_r reads the directory _d_i_r_n_a_m_e and builds an array of
  26.      pointers to directory entries using _m_a_l_l_o_c(3).  It returns
  27.      the number of entries in the array and a pointer to the
  28.      array through _n_a_m_e_l_i_s_t.
  29.  
  30.      The _s_e_l_e_c_t parameter is a pointer to a user supplied subrou-
  31.      tine which is called by _s_c_a_n_d_i_r to select which entries are
  32.      to be included in the array.  The select routine is passed a
  33.      pointer to a directory entry and should return a non-zero
  34.      value if the directory entry is to be included in the array.
  35.      If _s_e_l_e_c_t is null, then all the directory entries will be
  36.      included.
  37.  
  38.      The _c_o_m_p_a_r parameter is a pointer to a user supplied subrou-
  39.      tine which is passed to _q_s_o_r_t(3) to sort the completed
  40.      array. If this pointer is null, the array is not sorted.
  41.      _A_l_p_h_a_s_o_r_t is a routine which can be used for the _c_o_m_p_a_r
  42.      parameter to sort the array alphabetically.
  43.  
  44.      The memory allocated for the array can be deallocated with
  45.      _f_r_e_e (see _m_a_l_l_o_c(3)) by freeing each pointer in the array
  46.      and the array itself.
  47.  
  48. SSEEEE AALLSSOO
  49.      directory(3), malloc(3), qsort(3), dir(5)
  50.  
  51. DDIIAAGGNNOOSSTTIICCSS
  52.      Returns -1 if the directory cannot be opened for reading or
  53.      if _m_a_l_l_o_c(3) cannot allocate enough memory to hold all the
  54.      data structures.
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0            September 17, 1985                       1
  64.  
  65.  
  66.  
  67.